﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework;
using DSS_XNA.Engine.Entities;
using DSS_XNA.Engine.Error;
using DSS_XNA.Engine.World;
using Microsoft.Xna.Framework.Input;

namespace DSS_XNA.Engine.Graphics
{
    public class Sprite : Entity
    {
        #region Properties

        public static Texture2D DebugBBTextire
        {
            get { return Sprite._debugBBTextire; }
            set { Sprite._debugBBTextire = value; }
        }
        private static Texture2D _debugBBTextire = null;

        public Texture2D Texture
        {
            get { return _texture; }
            set { _texture = value; }
        }
        protected Texture2D _texture = null;

        public Sprite()
        {
        }

        public virtual void Render(SpriteBatch spriteBatch)
        {
            if (spriteBatch == null)
                throw new DSSException("'spriteBatch' is null.");

            Rectangle dest = new Rectangle();
            dest.X = (int)this.Position.X;
            dest.Y = (int)this.Position.Y;
            dest.Width = (int)this.WidthInPixels;
            dest.Height = (int)this.HeightInPixels;

            if (Game1.IsDebugMode)
            {
                if (DebugBBTextire != null)
                {
                    spriteBatch.Draw(DebugBBTextire, dest, Color.White);
                }
            }

            spriteBatch.Draw(this.Texture, dest, Microsoft.Xna.Framework.Graphics.Color.White);
        }

        public override int Update(GameTime gameTime, KeyboardState ks, MouseState ms, GamePadState gs)
        {
            return 1;
        }

        #endregion
    }
}
